<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>后退</button>
    <button>前进</button>
    <script>
      const back = document.querySelector("button:first-child");
      const forward = back.nextElementSibling;
      back.addEventListener("click", function () {
        // 后退
        // history.back()
        history.go(-1);
      });
      forward.addEventListener("click", function () {
        // 前进
        // history.forward()
        history.go(1);
      });
    </script>
  </body>
</html>
